local skel = fk.CreateSkill {
  name = "emo__yafang",
  tags = {Skill.Compulsory},
}

Fk:loadTranslationTable{
  ["emo__yafang"] = "压芳",
  [":emo__yafang"] = "锁定技，弃牌阶段结束时，你视为X名其他角色使用一张【杀】（X为此阶段进入弃牌堆的牌数）。",
  ["#emo__yankui-choose"] = "压芳：你须选择 %arg 名其他角色，视为对其使用一张【杀】",
}

skel:addEffect(fk.EventPhaseEnd, {
  anim_type = "offensive",
  events = {fk.EventPhaseEnd},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and player.phase == Player.Discard
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local n = 0
    room.logic:getEventsOfScope(GameEvent.MoveCards, 1, function(e)
      for _, move in ipairs(e.data) do
        if move.toArea == Card.DiscardPile then
          n = n + #move.moveInfo
        end
      end
      return false
    end, Player.HistoryPhase)
    local slash = Fk:cloneCard("slash")
    slash.skillName = skel.name
    if n == 0 or player:prohibitUse(slash) then return false end
    local targets = table.filter(room:getOtherPlayers(player, false), function(p) return not player:isProhibited(p, slash) end)
    if #targets == 0 then return false end
    if #targets > n then
      targets = room:askToChoosePlayers(player, {
        targets = targets,min_num = n, max_num = n, prompt = "#emo__yafang-choose:::"..n,
        skill_name = self.name, cancelable = false
      })
    end
    room:useCard{
      from = player, tos = targets, card = slash, extraUse = true
    }
  end,
})

return skel
